Skip to content

feat(macos): show receiver batteries in the Batteries widget - #1544

Open
flowsworld wants to merge 6 commits into
AprilNEA:masterfrom
flowsworld:feat/macos-battery-widget
Open

flowsworld wants to merge 6 commits into
AprilNEA:masterfrom
flowsworld:feat/macos-battery-widget

Conversation

@flowsworld

@flowsworld flowsworld commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Optionally show Bolt/Unifying mouse and keyboard batteries in the built-in macOS Batteries widget. Enable Show batteries in macOS widget in Settings > General. It is off by default; direct Bluetooth devices remain managed by macOS.

The integration uses dynamically loaded private IOKit functions and is experimental. macOS labels these published devices as Bluetooth even though they use a receiver.

Changes

  • Agent: publish measured percentage, charging state and device kind. Retain offline readings for five minutes and remove entries on disable/shutdown. Publish status independently of inventory scans and wake on adopted config changes.
  • Naming: the widget names a device like the low-battery notice from fix(agent-core): name low-battery notices by the persisted product name #2659: alias, then persisted product name, then tidied codename. Config::device_display_name now owns that order for both.
  • Core/IPC: persist the opt-in and append publisher status as protocol 47, after the v46 items released in v0.9.1-beta.144.
  • Desktop: macOS-only settings card with status and keyboard support. Renames reload the agent while the integration is enabled.

Rebased onto master at 0cae2818. The native control-center menu from #2455 is preserved.

Light Dark
Widget settings, light Widget settings, dark

The screenshots predate the #2190 restyle; the card itself is unchanged.

Testing

Apple Silicon macOS, Rust 1.100.1, RUSTFLAGS="-D warnings", rebased on 0cae2818:

  • cargo xtask ci: rustfmt, typos, ast-grep, publish closure, shell, clippy, MSRV (1.99), rustdoc, tests (macos, aarch64), cargo-deny, clippy (windows) proxy, clippy (macos) and wasm passed. 4,958 tests passed, 3 ignored.
  • tests (macos, x86_64) under Rosetta: all suites passed. Six test binaries needed /usr/lib/swift on the dyld fallback path on this host; the same happens in crates this PR does not touch.
  • Linux musl cross-lint passed with a temporary Zig C compiler.
  • cargo test -p openlogi-ipc --test wire_format: 39 passed. PROTOCOL_VERSION is 47.
  • After the naming fix, openlogi-core, openlogi-agent-core and openlogi-agent passed all-target Clippy, tests and rustdoc again. A new publisher test shows an unnamed device under its persisted product name.
  • Not run locally: tests (linux), tests (windows), native Windows clippy. Not tested on hardware, macOS 13 or Intel.

Merge coordination with #1588: both PRs append to protocol 47 and add the identical Config::device_display_name. The PR that lands second keeps 47 unless a release has shipped it, merges its history note into the v47 line, puts its wire items after the other's, and regenerates the shared snapshot/observation goldens before rerunning cargo test -p openlogi-ipc --test wire_format.

Hardware check: enable before the first inventory completes, verify status leaves Starting, connect receiver devices, check names/charging and rename updates, then disable and quit to verify cleanup.

The pin-project-lite lock entry moves from the yanked 0.2.17 to 0.2.19, the same change as #2723, so cargo-deny passes. A style-only commit ends two upstream KWin script files from #1003 with a newline. The repository's pre-push end-of-file hook checks every file changed since the old base and otherwise blocks the push.

Independent review: findings verified against the source. Fixed: widget naming and the openlogi api reload hint. Declined as rare paths: renaming an offline device during its grace period and re-pairing into another slot.

Reviewed with sol-loop: 3 rounds with gpt-6.2-sol on high. Sol verdict: approved

Fixes #669

@greptile-apps

greptile-apps Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge, with no accepted new findings or outstanding previous findings.

Summary

Adds an opt-in, experimental macOS Batteries-widget integration for Bolt and Unifying mice and keyboards.

  • Publishes battery percentage, charging state and device names through dynamically loaded IOKit functions, with five-minute offline retention and cleanup on disable or shutdown.
  • Adds configuration-change reconciliation, protocol-47 publisher status, and a macOS-only settings card.
  • The changes since the previous review only update pin-project-lite in Cargo.lock. No new actionable findings were established.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Settings["Settings preference or device rename"] --> Save["Persist configuration"]
    Save --> Adopt["Agent adopts configuration"]
    Adopt --> Reconcile["Reconcile battery publisher"]
    Inventory["Inventory snapshot"] --> Reconcile
    Timer["Retry or offline-expiry deadline"] --> Reconcile
    Reconcile --> Enabled{"Integration enabled?"}
    Enabled -->|Yes| Publish["Publish eligible receiver readings through IOKit"]
    Enabled -->|No| Clear["Release registrations"]
    Publish --> Status["Publish BatteryWidgetStatus through IPC"]
    Clear --> Status
    Status --> Footer["Settings status footer"]
Loading

Reviews (19) · Last reviewed commit: "build(deps): replace the yanked pin-proj..." · Reviewed by Greptile

@flowsworld
flowsworld force-pushed the feat/macos-battery-widget branch from 15edffe to 4864c08 Compare September 20, 2026 14:29
@sgade

sgade commented Sep 22, 2026

Copy link
Copy Markdown

I was thinking about implementing this change myself, and came across your recent PR.


No opinion on the actual code-level changes.

However, I was able to verify that it works on macOS 27.0, with a MX Master 4 via the USB dongle.
Shown here in the large battery widget.

Screenshot 2026-09-22 at 17 54 17

Comment thread crates/openlogi-agent/src/lifecycle.rs Resolved
@flowsworld
flowsworld force-pushed the feat/macos-battery-widget branch 3 times, most recently from cecdead to dd62ca3 Compare October 20, 2026 10:19
Comment thread crates/openlogi-ipc/src/ipc.rs Resolved
@flowsworld
flowsworld force-pushed the feat/macos-battery-widget branch from dd62ca3 to 79c0092 Compare October 21, 2026 16:41
@flowsworld
flowsworld force-pushed the feat/macos-battery-widget branch from 79c0092 to 5646b38 Compare November 4, 2026 08:44
@AprilNEA AprilNEA added the needs: decision Needs a maintainer/product decision label Nov 4, 2026 — with Manus Connector
@flowsworld
flowsworld force-pushed the feat/macos-battery-widget branch from 5646b38 to 66c2d1a Compare November 4, 2026 09:03
@flowsworld
flowsworld force-pushed the feat/macos-battery-widget branch from 66c2d1a to aa855f2 Compare November 12, 2026 10:27
Comment thread docs/CONFIGURATION.md Resolved
@davidbudnick davidbudnick added area: cli Command-line interface area: config Configuration files, persistence, and settings area: gui Graphical user interface area: tray Menu bar or system tray integration labels Nov 30, 2026
Upstream now names low-battery notices by the persisted product name.
The widget used only the alias or the raw codename, so an unnamed device
could appear under two names. Config::device_display_name now owns that
precedence for the notice and the widget. Hand edits can also be reloaded
with `openlogi api reload`.
@flowsworld
flowsworld force-pushed the feat/macos-battery-widget branch from a90206b to 2a347c0 Compare December 3, 2026 10:14

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command-line interface area: config Configuration files, persistence, and settings area: gui Graphical user interface area: tray Menu bar or system tray integration needs: decision Needs a maintainer/product decision platform: macos macOS-specific issue type: feature New feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Is it possible to add a macOS desktop widget that displays the mouse battery level?

4 participants